package com.gxa.controller.resume;

import com.gxa.common.R.ResponseData;
import com.gxa.pojo.Jianli;
import com.gxa.service.employee.SelectBoxService;
import com.gxa.service.resume.JianLiService;
import com.gxa.service.resume.impl.JianLiServiceImpl;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value ="人才储备",tags ="人才储备API" )
@Controller
@RequiresPermissions({"人才储备"})
@RequestMapping("/resume")
public class ResumeController {
    @Resource
    private JianLiService jianLiService;

    @Autowired(required = false)
    private SelectBoxService selectBoxService;

    /**
     * 查询所有简历信息
     * @return
     */
    @RequestMapping(value = "/selectAll",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询所有简历信息",notes = "查询简历信息",httpMethod = "get", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页数", required = true, dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数", required = true, dataType = "int"),
            @ApiImplicitParam(name = "name", value = "真实名字名字", required = true, dataType = "String")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData selectAll(@RequestParam int currentPage,
                                  @RequestParam int pageSize,
                                  @RequestParam String name){
        ResponseData responseData =  jianLiService.selectAll(currentPage, pageSize, name);
        return responseData;
    }

    /**
     * 根据状态查询所有的
     * @param status
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/selectByStatus",method = RequestMethod.GET)
    @ApiOperation(value = "根据状态查询简历信息",notes = "根据状态查询简历信息",httpMethod = "Get", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "简历状态", required = true, dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData selectByStatus(int status){
        return jianLiService.selectByStatus(status);
    }
    /**
     * 更改状态值
     * @param status
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/updateByStatus",method = RequestMethod.POST)
    @ApiOperation(value = "修改状态",notes = "录取或者拒绝",httpMethod = "post", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "简历状态（0：不能查看，1：可查看\n" +
                    "2：已录用，3：未录用 4：已入职，）", required = true, dataType = "int"),
            @ApiImplicitParam(name = "id", value = "简历id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "shuoMing", value = "相关说明", required = true, dataType = "String")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData updateByStatus(@RequestParam int id,
                                       @RequestParam int status,
                                       @RequestParam String shuoMing){
        return jianLiService.updateByStatus(id,status,shuoMing);
    }


    /**
     * 办理入职
     * @param jianli
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/insertEmployee",method = RequestMethod.POST)
    @ApiOperation(value = "办理入职",notes = "办理入职",httpMethod = "POST", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "简历id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "name", value = "该简历的人的姓名", required = true, dataType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话号码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "maxId", value = "最大员工id+1", required = true, dataType = "int"),
            @ApiImplicitParam(name = "entryDate", value = "入职时间", required = true, dataType = "String"),
            @ApiImplicitParam(name = "deptId", value = "部门id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "zhiCheng", value = "职称", required = true, dataType = "String"),
            @ApiImplicitParam(name = "zhiWu", value = "应聘岗位", required = true, dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData insertEmployee(@RequestBody Jianli jianli){
        return jianLiService.insertEmployee(jianli);
    }
    /**
     * 查询员工最大的id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/selectEmployeeId",method = RequestMethod.GET)
    @ApiOperation(value = "查询员工最大id+1",notes = "查询员工最大id+1",httpMethod = "Get", response = ResponseData.class)
    @ApiImplicitParams({
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData selectEmployeeId(){
        ResponseData responseData = jianLiService.selectEmployeeId();
        return responseData;
    }


    /**
     * 查询部门信息
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/SelectDept",method = RequestMethod.GET)
    @ApiOperation(value = "查询部门信息",notes = "查询部门信息",httpMethod = "Get", response = ResponseData.class)
    @ApiImplicitParams({
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData SelectDept(){
        return selectBoxService.selectAllDepartment();
    }
}
